from typing import Optional

from sqlalchemy import BigInteger, DateTime, Integer, PrimaryKeyConstraint, String, func, DECIMAL
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
import datetime

from config.database import Base
from utils.uuid import UUID


class CmsExpense(Base):
    __tablename__ = 'cms_expense'
    __table_args__ = (
        PrimaryKeyConstraint('id', name='_copy_22'),
        {'comment': '用车订单'}
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, default=int(UUID().uuid()))
    car_type: Mapped[Optional[str]] = mapped_column(String(32), comment='车辆型号')
    car_brand: Mapped[Optional[str]] = mapped_column(String(32), comment='车辆牌照')
    starting_price: Mapped[Optional[float]] = mapped_column(DECIMAL(10, 2), comment="起步价")
    miles_price: Mapped[Optional[float]] = mapped_column(DECIMAL(10, 2), comment="里程单价")
    day_price: Mapped[Optional[float]] = mapped_column(DECIMAL(10, 2), comment="固定整日")
    suspended_price: Mapped[Optional[float]] = mapped_column(DECIMAL(10, 2), comment="停延费")
    create_by: Mapped[Optional[str]] = mapped_column(String(32), comment='创建人-申请人')
    create_time: Mapped[datetime.datetime] = mapped_column(DateTime, comment='创建时间', server_default=func.now())
    update_by: Mapped[Optional[str]] = mapped_column(String(32), comment='修改人')
    update_time: Mapped[Optional[datetime.datetime]] = mapped_column(DateTime, comment='修改时间',
                                                                     server_default=func.now(), onupdate=func.now())
